package com.template.demo2.ads;

public abstract class CaffeineBeverageWithHook {

	public void prepareRecipe() {
		boilWater();
		brew();
		pourInCup();
		if (customerWantsCondiments()) {
			addCondiments();
		}
	}

	public abstract void brew();

	public abstract void addCondiments();

	public void boilWater() {
		System.out.println("Boiling water");
	}

	public void pourInCup() {
		System.out.println("Pouring into cup");
	}

	/**
	 * 定义钩子方法，可以让子类有能力对算法的不同点进行挂钩。要不要挂钩，由子类自行决定
	 * 
	 * @return
	 */
	public boolean customerWantsCondiments() {
		return true;
	}
}
